Ext.define("org.jks.DeviceReTjWindow", {
			extend : "Ext.panel.Panel",
			style:'border:1px solid #5bb6b1',
			border:false,
			width : 300,
			height : 250,
			closable : true,
			title : "飞巡统计",
			floating : true,
			modal : true,
			initComponent : function() {
				var me = this;
				
				var monthStore = Ext.create('Ext.data.Store', {
					fields : ['display', 'value'],
					data : [{
								"display" : "一月",
								"value" : 1
							}, {
								"display" : "二月",
								"value" : 2
							}, {
								"display" : "三月",
								"value" : 3
							}, {
								"display" : "四月",
								"value" : 4
							}, {
								"display" : "五月",
								"value" : 5
							}, {
								"display" : "六月",
								"value" : 6
							}, {
								"display" : "七月",
								"value" : 7
							}, {
								"display" : "八月",
								"value" : 8
							}, {
								"display" : "九月",
								"value" : 9
							}, {
								"display" : "十月",
								"value" : 10
							}, {
								"display" : "十一月",
								"value" : 11
							}, {
								"display" : "十二月",
								"value" : 12
							}]
				});

				var monthCom = Ext.create('Ext.form.ComboBox', {
					fieldLabel : '月份',
					labelWidth: 60,
					store : monthStore,
					editable : false,
					disabled : true,
					queryMode : 'local',
					displayField : 'display',
					valueField : 'value',
					id : 'monthCom'
				});
				
				var yearStore = Ext.create('Ext.data.Store', {
					fields : ['display', 'value'],
					data : [{
								"display" : "2015",
								"value" : 2015
							}, {
								"display" : "2016",
								"value" : 2016
							}, {
								"display" : "2017",
								"value" : 2017
							}, {
								"display" : "2018",
								"value" : 2018
							}, {
								"display" : "2019",
								"value" : 2019
							}, {
								"display" : "2020",
								"value" : 2020
							}, {
								"display" : "2021",
								"value" : 2021
							}, {
								"display" : "2022",
								"value" : 2022
							}, {
								"display" : "2023",
								"value" : 2023
							}, {
								"display" : "2024",
								"value" : 2024
							}, {
								"display" : "2025",
								"value" : 2025
							}, {
								"display" : "2026",
								"value" : 2026
							}]
				});

				var yearCom = Ext.create('Ext.form.ComboBox', {
					fieldLabel : '年份',
					labelWidth: 60,
					store : yearStore,
					editable : false,
					queryMode : 'local',
					displayField : 'display',
					valueField : 'value',
					id : 'yearCom'	
				});
				
				var typeStore = Ext.create('Ext.data.Store', {
					fields : ['display', 'value'],
					data : [{
								"display" : "年度统计",
								"value" : 1
							}, {
								"display" : "月度统计",
								"value" : 2
							}]
				});

				var typeCom = Ext.create('Ext.form.ComboBox', {
					fieldLabel : '统计方式',
					labelWidth: 60,
					id : 'typeCom',
					store : typeStore,
					editable : false,
					queryMode : 'local',
					displayField : 'display',
					valueField : 'value',
					value : 1,
					listeners : {
						change: function(self, newValue, oldValue){
							if(newValue == 1)
							{
								yearCom.setDisabled(false);
								monthCom.setDisabled(true);
							}
							else if(newValue == 2)
							{
								yearCom.setDisabled(false);
								monthCom.setDisabled(false);
							}
						}
					}
				});
		
				var form = Ext.create("Ext.form.Panel",{
					border : false,
					margin: '20',
					items : [typeCom, yearCom, monthCom]
				});
				me.items = [form]
				
				
				me.okButton = Ext.create('Ext.button.Button', {
					text : '确定',
					handler : function() 
					{
						me.exportRe();
					}
				});
				me.cancelButton = Ext.create('Ext.button.Button', {
							text : '取消',
							handler : function() {
								me.close();
							}
						});
				me.buttons = [me.okButton, me.cancelButton];
				me.callParent();
			},
			exportRe : function()
			{
				var me = this;
				var type = Ext.getCmp('typeCom').getValue();
				var year = Ext.getCmp('yearCom').getValue();
				var month =Ext.getCmp('monthCom').getValue();
				if(type == 1)
				{
					if(Ext.isEmpty(year))
					{
						Ext.Msg.alert('错误', '请选择统计年份');
						return;
					}
				}
				else if(type == 2)
				{
					if(Ext.isEmpty(year))
					{
						Ext.Msg.alert('错误', '请选择统计年份');
						return;
					}
					if(Ext.isEmpty(month))
					{
						Ext.Msg.alert('错误', '请选择统计月份');
						return;
					}					
				}
				year = Ext.isEmpty(year) ? -1 : year;
				month = Ext.isEmpty(month) ? -1 : month;
					
				window.open('/device/exportDeviceReTj/' + type + '/' + year + '/' + month);
				me.close();
					
			}
		});